package com.zhongyu.item.consumer.service.Impl;

import com.zhongyu.comm.pojo.ItemType;
import com.zhongyu.item.consumer.client.CinemaClient;
import com.zhongyu.item.consumer.client.ImageClient;
import com.zhongyu.item.consumer.client.ItemClient;
import com.zhongyu.item.consumer.client.ItemTypeClient;
import com.zhongyu.item.consumer.service.IndexDaoHangService;
import com.zhongyu.item.consumer.vo.DaoHangVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Service("indexDaoHangService")
public class IndexDaoHangServiceImpl implements IndexDaoHangService {

    @Resource
    private ItemTypeClient itemTypeClient;

    @Override
    public List<DaoHangVo> searchDaoHang() {
        List<ItemType> itemType = itemTypeClient.findAll();
        return itemType.stream().map(itemType1 -> {
            DaoHangVo daoHangVo = new DaoHangVo();
            daoHangVo.setId(itemType1.getId());
            daoHangVo.setItemType(itemType1.getItemType());
            daoHangVo.setLevel(itemType1.getLevel());
            daoHangVo.setAliasName(itemType1.getAliasName());
            daoHangVo.setKey(itemType1.getKey());
            return daoHangVo;
        }).collect(Collectors.toList());
    }
}
